//
//  WDFaBuViewController.m
//  qiJi
//
//  Created by 凤利史 on 2018/4/12.
//  Copyright © 2018年 sunrose. All rights reserved.
//

#import "WDFaBuViewController.h"
#import "WDFaBuFirstTableViewCell.h"
#import "WDFaBuTwoTableViewCell.h"
#import "WDFaBuThreeTableViewCell.h"
#import "HYRootXiangQingViewController.h"
@interface WDFaBuViewController ()<UITableViewDelegate, UITableViewDataSource>
@property (nonatomic, strong) UITableView *tableView;
@property (nonatomic, strong) NSMutableArray *dataArr;

@end

@implementation WDFaBuViewController
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    
    
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    
    
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的发布";
    [self creationView];
    [self regeditCell];
    // Do any additional setup after loading the view.
}
- (void)creationView{
    
    UIView *threadView = [[UIView alloc]initWithFrame:CGRectMake(0, 1, DEF_SCREEN_WIDTH, 1)];
    threadView.backgroundColor = getColor(@"E6E6E6");
    [self.view addSubview:threadView];
    self.tableView = [[UITableView alloc] init];
    self.tableView.frame = CGRectMake(0, 2, DEF_SCREEN_WIDTH, DEF_SCREEN_HEIGHT - (KIsiPhoneX?84:64) - 2);
    
    self.tableView.tableFooterView = [[UITableView alloc] initWithFrame:CGRectZero];
    
    self.tableView.backgroundColor = [UIColor whiteColor];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.tableView.estimatedRowHeight = 80;
    [self.view addSubview:self.tableView];
    if (@available(iOS 11.0, *)) {
        
        UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        
    } else {
        
        // Fallback on earlier versions
        
    }
    
    //如果你的cell 之间的间距拉大，就在self.xf_tableView.contentInset = UIEdgeInsetsMake(64, 0, 0, 0);这个约束后面添加下面三个约束
    
    self.tableView.estimatedRowHeight = 0;
    
    self.tableView.estimatedSectionHeaderHeight = 0;
    
    self.tableView.estimatedSectionFooterHeight = 0;
    
}
- (void)regeditCell{
    
    
    
    [self.tableView registerNib:[UINib nibWithNibName:@"WDFaBuFirstTableViewCell" bundle:nil] forCellReuseIdentifier:@"WDFaBuFirstTableViewCell"];
    
    [self.tableView registerNib:[UINib nibWithNibName:@"WDFaBuTwoTableViewCell" bundle:nil] forCellReuseIdentifier:@"WDFaBuTwoTableViewCell"];
    [self.tableView registerNib:[UINib nibWithNibName:@"WDFaBuThreeTableViewCell" bundle:nil] forCellReuseIdentifier:@"WDFaBuThreeTableViewCell"];
    
}

#pragma mark - ---------- Section的数量 ----------
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 5;
}

#pragma mark - ---------- 每个Section的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0;
}

#pragma mark - ---------- Cell的数量 ----------
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 3;
    
    
}

#pragma mark - ---------- 每个Cell的高度 ----------
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (indexPath.row == 0) {
        return 65;
    }else if (indexPath.row == 1){
        return 153;
        
    }else{
       return UITableViewAutomaticDimension;
    }
    
    
}
#pragma mark - ---------- 每个Cell的内容 ----------
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSMutableDictionary *dic = self.dataArr[indexPath.section];
    
    if (indexPath.row == 0) {
        WDFaBuFirstTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"WDFaBuFirstTableViewCell" forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
    }else if (indexPath.row == 1){
        
        WDFaBuTwoTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"WDFaBuTwoTableViewCell" forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
        
    }else{
        WDFaBuThreeTableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:@"WDFaBuThreeTableViewCell" forIndexPath:indexPath];
        
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
    
    
    
}

#pragma mark - ---------- 每个Cell的点击事件 ----------
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    HYRootXiangQingViewController *vc = [[HYRootXiangQingViewController alloc] init];
    [self.navigationController pushViewController:vc animated:YES];
    
    
    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
